<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1.0" />
    <title>弹出推荐图片详情</title>
    <#include "/view/admin/head.html"/>
    <script type="text/javascript" src="${base}/jstool/bootstrap-switch/bootstrap-switch.min.js"></script>
    <script type="text/javascript" src="${base}/jstool/bootstrap-fileinput/js/fileinput.js"></script>
    <script type="text/javascript" src="${base}/jstool/bootstrap-fileinput/js/locals/zh.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-switch/bootstrap-switch.min.css" />
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-fileinput/css/fileinput.min.css" />
    <style type="text/css">
        .list-path{
            height: 50px;
            line-height: 50px;
            background-color: #9acfea;

        }
        .table-class{
            width:90%;
            text-align: center;
            border:1px solid #afd9ee;
            margin:0 auto;
            margin-top: 50px;
        }
        table th{
            width:20%;
            background-color: #d9edf7;
            text-align: right;
        }
        table td{
            width:20%;
            text-align: left;
        }

    </style>
    <script type="text/javascript">
        $(function () {
            $('.label-write').css('display','none');
            $('.btn-save').css('display','none');
            $('.btn-cansel').css('display','none');
            $('#picPath').fileinput({
                language: 'zh', //设置语言
                allowedFileExtensions : ['jpg', 'png','gif'],//接收的文件后缀
                showUpload: false, //是否显示上传按钮
                showCaption: false,//是否显示标题
                browseClass: "btn btn-primary", //按钮样式
                previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
            });
            $('[name="display"]').bootstrapSwitch({
                onText:"显示",
                offText:"隐藏",
                onColor:"success",
                offColor:"info",
                size:"small",
                onSwitchChange:function(event,state){
                    if(state==true){
                        $(this).val("1");
                    }else{
                        $(this).val("0");
                    }
                }
            });
            $('[name="usetemplate"]').bootstrapSwitch({
                onText:"是",
                offText:"否",
                onColor:"success",
                offColor:"info",
                size:"small",
                onSwitchChange:function(event,state){
                    if(state==true){
                        $(this).val("1");
                    }else{
                        $(this).val("0");
                    }
                }
            });
        });



    </script>
</head>
<body>

<div class="list-path" > <span style="margin-left: 50px;"> <a href="${base}/recommendpic/list.do"><span class="glyphicon glyphicon-home"></span> 弹出推荐图片列表</a>  / 弹出推荐图片详情</span>
    <div style="float: right; margin-right: 40px;">
        <a class="btn btn-info"
           href="${base}/recommendpic/list.do">返回</a>
    </div>
    <div style="float:right;margin-right: 40px;"><a class="btn btn-info" href="${base}/recommendpic/detail.do?id=${entity.recommendpicId}">刷新</a>

    </div>
</div>


<div class="table-class">
    <#if msg??>
        <div class="alert alert-error" style="background-color: #f2dede;color: #a94442;">
            <a class="close" data-dismiss="alert">×</a>
            <strong>错误!</strong>${msg!}
        </div>
    </#if>
    <form id="form1" action="${base}/recommendpic/save.do" method="post" enctype="multipart/form-data">
        <table class="table table-bordered">
            <tr>
                <th colspan="4" style="text-align: center">微信用户信息详情</th>
            </tr>
            <tr style="display: none">
                <th>微信用户openid</th>
                <td><input type="text" hidden name="openid" value="${weixininfo.openid!}"/></td>
                <th>弹出推荐id</th>
                <td><input type="text" hidden name="recommendpicId" value="${entity.recommendpicId!}"/></td>
            </tr>
            <tr>
                <th>昵称</th>
                <td>${weixininfo.nickname!}</td>
                <th rowspan="2">头像</th>
                <td rowspan="2"><img src="${weixininfo.headimgurl!}" height="70px"></td>

            </tr>
            <tr>
                <th>性别</th>
                <td>
                    <#if weixininfo.sex??>
                        <#if 1==weixininfo.sex>男</#if>
                        <#if 2==weixininfo.sex>女</#if>
                    </#if>
                </td>
            </tr>
            <tr>
                <th>省份</th>
                <td>${weixininfo.province!}</td>
                <th>城市</th>
                <td>${weixininfo.city!}</td>
            </tr>
            <tr>
                <th>国家</th>
                <td>${weixininfo.country!}</td>
                <th>录入时间</th>
                <td><#if (weixininfo.createtime)?? >${weixininfo.createtime?string('yyyy-MM-dd HH:mm')}</#if></td>

            </tr>
            <tr>
                <td colspan="4" >&nbsp;</td>
            </tr>
            <tr>
                <th colspan="4" style="text-align: center">弹出推荐图片详情

                </th>
            </tr>
            <tr>
                <th>标题</th>
                <td><span class="label-view">${entity.title!}</span>
                    <span class="label-write">
                <input type="text" class="form-control" id="title" name="title"
                       placeholder="请输入标题" value="${entity.title!}">
                </span>
                </td>
                <th>外链接</th>
                <td><span class="label-view">${entity.url!}</span>
                    <span class="label-write"><input type="text" class="form-control" name="url" placeholder="请输入外链接" value="${entity.url!}"/> </span>
                </td>
            </tr>
            <tr>
                <th>图片地址</th>
                <td><span class="label-view"><img src="${base}${entity.picPath!}" height="100px"></span>
                    <span class="label-write"><input id="picPath" type="file" name="file" value="${entity.picPath!}"/> </span>
                </td>
                <th>最近弹出时间</th>
                <td><#if (c.updateDate)?? >${c.updateDate?string('yyyy-MM-dd HH:mm')}</#if>
                </td>

            </tr>
            <tr>
                <th>显示或隐藏</th>
                <td>
               <span class="label-view">
                   <#if entity.display??>
                       <#if 0==entity.display><span class="label label-default">隐藏</span></#if>
                       <#if 1==entity.display><span class="label label-success">显示</span></#if>
                    </#if>
               </span>
                    <span class="label-write">
                   <input name="display" type="checkbox"  data-size="small"
              <#if entity.display??>
                   <#if 1==entity.display>checked="checked" value="1"</#if>
                   <#if 0==entity.display> value="0"</#if>

               </#if>
                />
               </span>

                </td>
                <th>创建时间</th>
                <td>
                    <#if (entity.createtime)?? >${entity.createtime?string('yyyy-MM-dd HH:mm')}</#if>
                </td>

            </tr>
            <tr>
                <th>使用默认模板显示</th>
                <td>
               <span class="label-view">
                   <#if entity.usetemplate??>
                       <#if 0==entity.usetemplate><span class="label label-default">否</span></#if>
                       <#if 1==entity.usetemplate><span class="label label-success">是</span></#if>
                    </#if>
               </span>
                    <span class="label-write">
               <input name="usetemplate" type="checkbox"  data-size="small"
                <#if entity.usetemplate??>
                    <#if 1==entity.usetemplate>checked="true" value="1"</#if>
                    <#if 0==entity.usetemplate>checked="false" value="0"</#if>

                </#if>
                />


                </span>

                </td>


            </tr>
            <tr>
                <td colspan="4" width="100%" style="text-align: center;">
                    <input type="button" class="btn btn-success isuse-btn btn-update" onclick="update();" value="修改"/>
                    <input type="button" class="btn btn-success isuse-btn btn-save" onclick="save();" value="保存"/>
                    <input type="button" class="btn btn-danger isuse-btn btn-cansel" onclick="cansel();" value="取消"/>
                </td>

            </tr>
        </table>
    </form>
</div>

<script type="text/javascript">
    function update(){
        $('.label-view').css('display','none');
        $('.label-write').css('display','');
        $('.btn-update').css('display','none');
        $('.btn-cansel').css('display','');
        $('.btn-save').css('display','');
    }
    function cansel(){
        $('.label-view').css('display','');
        $('.label-write').css('display','none');
        $('.btn-cansel').css('display','none');
        $('.btn-update').css('display','')
        $('.btn-save').css('display','none')
    }
    function save(){
//        $('.btn-save').attr('disabled',"disabled");
//        location.href="${base}/recommendpic/save.do";
        console.log($("input[name='display']").val());
        console.log($("input[name='usetemplate']").val());
        $('#form1').submit();
    }
</script>

</body>
</html>